package cn.edu.scau.cmi.chensixiao.domain;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class Teacher implements java.io.Serializable {
 
  private Long id;
  private String name;
  private Set students = new HashSet(0);

  public Teacher() {
	  
  }
  
  public Teacher(String name) {
	  this.name = name;
	  
  }

  public Long getId() {
    return this.id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Set getStudents() {
	  if(students != null) {
		    return this.students;
	  }else {
		  return null;
	  }
  }

  public void setStudents(Set students) {
    this.students = students;
  }
  
  @Override
  public boolean equals(Object teacher) {
	  if(teacher instanceof Teacher && this.id == ((Teacher)teacher).id) {
		  return true;
	  }
	  return false;
  }
  
  @Override 
  public int hashCode() {
	  return Objects.hash(id,name);
  }
  
  @Override
  public String toString() {
	  StringBuilder result = new StringBuilder();
	  result.append("工号： "+ this.getId() + "\t\t\t");
	  result.append("姓名： " + this.getName() + "\n");
	  return result.toString();
  }
}
